<template>
    <div class="view">
		<div class="page-statistics">
			<div class="m-header">
				<div class="name">《{{pageInfo.name ? pageInfo.name:''}}》</div>
				<div class="right_box">
					<span>{{poetyInfo.className ? poetyInfo.className :''}}</span>
					<span>平均分：{{pageInfo.average ? pageInfo.average :0}}分</span>
					<span>参与人数：{{pageInfo.count ? pageInfo.count :0 }}人</span>
				</div>
			</div>
			<div class="m-con">
				<div class="list">
					<div class="list-item" v-for="(item,index) in poetryList" :key="'index' +index" @click="jumpCheck(item)">
						<div class="order">{{index +1}}</div>
						<img class="Img" :src="item.avatar?item.avatar:headError" alt="" :onerror="headError">
						<div class="name">{{item.name}}</div>
						<div class="num">{{item.score?item.score:0}}分</div>
					</div>
				</div>
					<div class="vTips_empty" v-if="!poetryList || !poetryList.length">暂无数据</div>
			</div>
		</div>
	</div>
</template>

<script>
import * as api from '@/api/index';
import { mapActions } from "vuex";
export default {
	data() {
		return {
			poetyInfo: {},
			pageInfo:{},
			poetryList:[],
			headError: this.$store.state.headError,
		};
	},
	created(){
		this.getInit()
	},
	methods: {
		getInit(){
			var poetyObj = sessionStorage.getItem('poetyInfo');
			if(!poetyObj){
				this.$router.push({ path: '/poetry/poetyList'})
				return false
			}
			this.poetyInfo = poetyObj?JSON.parse(poetyObj):{}
			this.getList()

		},
		async getList(){
			var res=await api.getPoetryScoreDetailByClass(this.poetyInfo)
			if(res.resultCode==1){
				this.pageInfo = res.value?res.value:{}
				this.poetryList = this.pageInfo.poetryScoreList?this.pageInfo.poetryScoreList:[]
			}
		},


		...mapActions(['setPoeId']),
		jumpCheck(item){
			console.log(item,"item")
			window.sessionStorage.setItem('selUserInfo',JSON.stringify(item));
			window.sessionStorage.setItem('curPoetryId',this.poetyInfo.poetryId);
			// this.setPoeId(item.poetryId)
			this.$router.push({
				path: '/poetry/player',
				query:{
					userId:item.userId,
					poeid:this.poetyInfo.poetryId,
					type:this.poetyInfo.type  //诗词类型
				}
			})
			// localStorage.setItem('info',JSON.stringify(item)  )
		}
	}
};
</script>

<style lang="scss" scoped>
.page-statistics{
	padding: 0.3rem 0.4rem;
}
.m-header {
	height: 1.5rem;
	font-size: 0.45rem;
	color: #05b3b6;
	border-bottom: 0.05rem dotted #e6eedb;
	font-weight: bold;
	.name{
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.right_box {
		display: flex;
		margin-top: 0.2rem;
		font-size: 0.28rem;
		span{
			padding-left: 0.2rem;
		}
	}
}
.m-con {
	padding: 0 0 2.4rem 0;
	width: 100%;
	.list{
		flex: 1;
		overflow: auto;
	}
	.list-item {
		display: flex;
		height: 1rem;
		align-items: center;
		line-height: 1rem;
		text-align: center;
		font-size: 0.36rem;
		color: #333333;
		padding-right: .2rem;
		.order {
			color: #05b3b6;
			font-size: 0.32rem;
			width: .5rem;
			text-align: center;
		}
		.Img {
			width: 0.6rem;
			height: 0.6rem;
			border-radius: 0.3rem;
			margin-left: 0.4rem;
		}
		.name {
			width: 2.5rem;
			text-align: left;
			margin-left: 0.4rem;
		}
		.num {
			flex: 1;
			text-align: right;
		}
	}
}
</style>